﻿/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Page1={
    create:function () {
    var page={};
        page.ui=new PIXI.DisplayObjectContainer();
        // var bg=new PIXI.Graphics();
        // bg.beginFill(0xffffff,1);
        // bg.drawRect(0,0,740,1136);
        // bg.endFill();
        // page.ui.addChild(bg);
        var bg=new PIXI.Sprite(resource['assets/images/p1_bg.png'].texture);
        page.ui.addChild(bg);

        var t0=new PIXI.Sprite(resource['assets/images/p1_t0.png'].texture);
        t0.anchor.set(0.5);
        t0.x = 370;
        t0.y =100;
        page.ui.addChild(t0);

        var t1=new PIXI.Sprite(resource['assets/images/p1_t1.png'].texture);
        t1.anchor.set(0.5);
        t1.x = 374;
        t1.y = 420;
        page.ui.addChild(t1);

        //var t2=new PIXI.Sprite(resource['assets/images/p1_t2.png'].texture);
        //t2.anchor.set(0.5);
        //t2.x = 382;
        //t2.y = 346;
        //page.ui.addChild(t2);
        var style = new PIXI.TextStyle({
            fontSize: 60,
            fontWeight: 'bold',
            fill: ['#BF9164', '#BF9164'], // gradient
            wordWrap: true,
            wordWrapWidth: 440
        });

        var t2 = new PIXI.Text(textName, style);
        t2.anchor.set(0.5,0.5);
        t2.x = 388;
        t2.y = 707;
        page.ui.addChild(t2);

        var t3=new PIXI.Sprite(resource['assets/images/p1_t3.png'].texture);
        t3.anchor.set(0.5);
        t3.x = 384;
        t3.y = 795;
        page.ui.addChild(t3);

        var t4=new PIXI.Sprite(resource['assets/images/p1_t4.png'].texture);
        t4.anchor.set(0.5);
        t4.x = 388;
        t4.y = 944;
        // page.ui.addChild(t4);
        // t4.interactive=true;
        // t4.on('pointertap',tapHandler);

        var t5=new PIXI.Sprite(resource['assets/images/p1_t5.png'].texture);
        t5.anchor.set(0.5);
        t5.x = 386;
        t5.y = 1074;
        page.ui.addChild(t5);

        page.In=function(){
            if(textName=='')
            {
                textName='无名';
            }
            t2.text=textName;

            bg.alpha=0;
            TweenMax.to(bg,1,{delay:0.2*0,alpha:1,ease:Linear.easeNone});

            time=setInterval(function () {
                createCircle();
            },1000);

            // i0.scale.x=i0.scale.y=i0.alpha=0;
            // i1.scale.x=i1.scale.y=i1.alpha=0;
            // i2.scale.x=i2.scale.y=i2.alpha=0;
            // i0.rotation=-Math.PI*2;
            // i1.rotation=Math.PI*1;
            // i2.rotation=Math.PI/2;
            // TweenMax.to(i0,1.5,{delay:1.5,alpha:1,rotation:0,ease:Back.easeOut});
            // TweenMax.to(i0.scale,1.5,{delay:1.5,  x:1,y:1,ease:Back.easeOut,onComplete:function()
            // {
            //     TweenMax.to(i0,5,{rotation:Math.PI*2,repeat:-1,ease:Linear.easeNone});
            // }});
            //
            // TweenMax.to(i1,1.5,{delay:1.7,alpha:1,rotation:0,ease:Back.easeOut});
            // TweenMax.to(i1.scale,1.5,{delay:1.7,x:1,y:1,ease:Back.easeOut,onComplete:function()
            // {
            //     TweenMax.to(i1,10,{rotation:-Math.PI*2,repeat:-1,ease:Linear.easeNone});
            // }});
            //
            // TweenMax.to(i2,1.5,{delay:2.0,alpha:1,rotation:0,ease:Back.easeOut});
            // TweenMax.to(i2.scale,1.5,{delay:2.0,x:1,y:1,ease:Back.easeOut,onComplete:function()
            // {
            //     TweenMax.to(i2,15,{rotation:Math.PI*2,repeat:-1,ease:Linear.easeNone});
            // }});

            t0.scale.x=t0.scale.y=0;
            t1.scale.x=t1.scale.y=0;
            t2.scale.x=t2.scale.y=0;
            t3.scale.x=t3.scale.y=0;
            t4.scale.x=t4.scale.y=0;
            t5.scale.x=t5.scale.y=0;
            TweenMax.to(t0.scale,1,{delay:2+0.2*1,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t1.scale,1,{delay:2+0.2*2,x:1,y:1,ease:Cubic.easeOut,onComplete:function () {
                TweenMax.to(t1.scale,1,{x:0.95,y:0.95,repeat:-1,yoyo:true,ease:Cubic.easeInOut});
            }});
            TweenMax.to(t2.scale,1,{delay:2+0.2*3,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t3.scale,1,{delay:2+0.2*4,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t4.scale,1,{delay:2+0.2*5,x:1,y:1,ease:Back.easeOut});

            document.getElementById('img_qr').style.zIndex=15;
            document.getElementById('img_qr').style.opacity=0;
            TweenMax.to( document.getElementById('img_qr').style,1,{delay:2+0.2*5,opacity:1,ease:Back.easeOut});
            TweenMax.to(t5.scale,1,{delay:2+0.2*6,x:1,y:1,ease:Back.easeOut});






            // setInterval(function()
            // {
            //     circleDownHandler();
            // },1000);
        }
        function createCircle()
        {
            for(var i=0;i<15;i++)
            {
                var circle=Circle.create(0,0,0x577fa0);
                page.ui.addChild(circle.ui);

                circle.ui.x=369;
                circle.ui.y=400;

                circle.ui.scale.x=0.0;
                circle.ui.scale.y=0.0;
                circle.ui.alpha=0.0;
                TweenMax.to(circle.ui,0.25,{delay:0.1*i,alpha:1,ease:Linear.easeNone,onCompleteParams:[circle],onComplete:function (c) {
                    TweenMax.to(c.ui,0.25,{delay:0,alpha:0,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                        TweenMax.to(c.ui,0.25,{delay:0,alpha:1,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                            TweenMax.to(c.ui,0.25,{delay:0,alpha:0,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                                TweenMax.to(c.ui,0.25,{delay:0,alpha:1,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                                    TweenMax.to(c.ui,0.25,{delay:0,alpha:0,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                                        TweenMax.to(c.ui,0.25,{delay:0,alpha:1,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {
                                            TweenMax.to(c.ui,0.25,{delay:0,alpha:0,ease:Linear.easeNone,onCompleteParams:[c],onComplete:function (c) {

                                            }});
                                        }});
                                    }});
                                }});
                            }});
                        }});
                    }});
                }});
                // TweenMax.to(circle.ui,0.5,{alpha:1});
                // TweenMax.to(circle.ui,0.5,{delay:0.5,alpha:0});
                // TweenMax.to(circle.ui,0.5,{delay:1,alpha:1});
                // TweenMax.to(circle.ui,0.5,{delay:1.5,alpha:0});

                TweenMax.to(circle.ui.scale,3,{delay:0.1*i,x:0.52-i*0.0,y:0.52-i*0.0,onCompleteParams:[circle],onComplete:function (c) {

                    c.ui.parent.removeChild(c.ui);
                    c=null;
                }});
            }
        }

        function tapHandler(e)
        {
            window.location.href='https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI0MDQ4MTY4Nw==&scene=110#wechat_redirect';
        }

    return page;
    }
}